package com.hn.y.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hn.y.entity.User;
import com.hn.y.mapper.primary.mapper.UserMapper;
import com.hn.y.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jun
 * @since 2021-01-15
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userServiceImpe;

    @GetMapping(value = "/selectAll")
    public List<User> selectAll(){
        UserMapper mapper = userServiceImpe.getBaseMapper();
        List<User> userList = mapper.selectList(null);
        userList.forEach(System.out::println);
        return  userList;
    }

    /**
     *  测试mybatis-plus分页插件
     */
    @GetMapping(value = "/selectPage")
    public List<User> selectPage(){
        UserMapper baseMapper = userServiceImpe.getBaseMapper();
        Page<User> page = new Page<>(2,2);
        baseMapper.selectPage(page, null);
        List<User> userList = page.getRecords();
        return userList;
    }

}
